<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/6/4
 * Time: 17:27
 */
namespace App\Modules\Jobs\Services;
use App\Modules\User\Models\UserRecommend;
use Redis;

class UpdateSelfRecoService {
    /**
     * 更新自荐表被查看次数
     */
    static function RecommendReadTimes($uid){
        $readTime = Redis::hget('self_recommend_info:'.$uid, 'readTimes');

        if ($readTime ) {
            $readTime++;
        }else{
            $readTime = UserRecommend::RecommendReadTimes($uid);
        }
        Redis::hset('self_recommend_info:'.$uid, 'readTimes',$readTime);
        return $readTime;
    }

    /**
     * 更新用户自荐表数
     */
    static function RecommendTimes($uid){
        $recommendTimes = Redis::hget('self_recommend_info:'.$uid, 'recommendTimes');

        if ($recommendTimes ) {
            $recommendTimes++;
        }else{
            $recommendTimes = UserRecommend::RecommendTimes($uid);
        }
        Redis::hset('self_recommend_info:'.$uid, 'recommendTimes',$recommendTimes);
        return $recommendTimes;
    }
    /**
     * 更新用户自荐成功次数
     */
    static function RecommendSuccessTimes($uid){
        $RecommendSuccessTimes = Redis::hget('self_recommend_info:'.$uid, 'recommendSuccessTimes');

        if ($RecommendSuccessTimes ) {
            $RecommendSuccessTimes++;
        }else{
            $RecommendSuccessTimes = UserRecommend::RecommendTimes($uid);
        }
        Redis::hset('self_recommend_info:'.$uid, 'recommendSuccessTimes',$RecommendSuccessTimes);
        return $RecommendSuccessTimes;
    }

}